#include "unet/icmp.h"

void
unet_icmp_incoming_packet (struct in_addr ip_addr, const uint8_t *packet, const uint32_t len)
{
  struct icmphdr *header = (void *) packet;

  switch (header->type)
    {
    case ICMP_ECHO:
      {
	struct icmphdr reply;

	reply.type = ICMP_ECHOREPLY;
	reply.code = 0;  /* Always 0 for echo replies. */
	reply.un.echo.id = header->un.echo.id;
	reply.un.echo.sequence = header->un.echo.sequence;

	unet_ip_icmp_send_packet (ip_addr, &reply, sizeof (reply));
	break;
      }
    }
}
